$(document).ready(function(){
	$("#accordion").accordion({ 
		header: "h3",
		autoHeight: false,
		navigation: true,
		collapsible: true,
		active: $.cookie('accordion_active'),
		changestart: function(event, ui) {
			$.cookie('accordion_active',$('#accordion h3').index(ui.newHeader));
		}
	}); 
	
	$('#collapse-accordion').attr('title','Hiện cột trái');
	$('#collapse-accordion').click(function(){
		var tmp=$(this);
		tmp.hide('fast');
		if($('#accordion').css('display')!='none')
		{
			$('#accordion').hide('slide',{direction:'left'},'slow', function() {
				$('#td-first').addClass('hide');
				$('#td-first').removeClass('show');
				tmp.addClass('hide');
				tmp.removeClass('show');
				tmp.find('span').removeClass('ui-icon-triangle-1-w');
				tmp.find('span').addClass('ui-icon-triangle-1-e');
				tmp.attr('title','Hiện cột trái');
				$.cookie('collapse_accordion','hide');
				tmp.show('fast');
			});	
		}
		else
		{
			$('#accordion').show('slide',{direction:'left'},'slow', function() {
				$('#td-first').addClass('show');
				$('#td-first').removeClass('hide');
				tmp.addClass('show');
				tmp.removeClass('hide');
				tmp.find('span').addClass('ui-icon-triangle-1-w');
				tmp.find('span').removeClass('ui-icon-triangle-1-e');
				tmp.attr('title','Ần cột trái');
				$.cookie('collapse_accordion','show');
				tmp.show('fast');
			});
			
		}
	})
	
	$('#main-table td:first-child').animate({opacity: 1}, 'fast');
})	
